import { Modal } from "antd";
import { Component, ReactNode } from "react";
import AddNoticeFrom from './AddNoticeFrom'

interface AddNoticeProps {
    visible?: boolean;  // 可选属性
    close?: () => void;  // 可选属性，类型为函数，无返回值
}

class AddNotice extends Component<AddNoticeProps> {

  constructor(props: AddNoticeProps) {
    super(props);
    this.closeModal = this.closeModal.bind(this);
  }

  closeModal = () => {
    this.props.close && this.props.close();
  }
  render() {
    return (
      <>
        <Modal
        width='800px'
          visible={this.props.visible}
          title="发布公告"
          cancelText="取消" 
          onCancel={() => this.props.close && this.props.close()} // 调用父组件的 close 方法
          okButtonProps={{ style: { display: 'none' } }} // Remove the OK button
          destroyOnClose
        >
          <AddNoticeFrom    closeModal={this.closeModal} />

        </Modal>
      </>
    );
  }
}

export default AddNotice;
